from pathlib import Path


def data_processing_pipeline(filename):
    """数据处理管道"""

    file_path = Path(__file__).parent / filename

    with open(file_path, "r", encoding="utf-8") as f:
        # 1 读取带ERROR的日志行并放到一个生成器中
        for line in f:
            if "ERROR" in line:
                yield line


# 使用管道
get_error_generatore = data_processing_pipeline("java.log")

convert_lower_generator = (
    f"{idx}:{line}" for idx, line in enumerate(get_error_generatore)
)

for err_log in convert_lower_generator:
    print(err_log)
